/**
 * ____________________ *
 *  ____ ____ ____ _  _ *
 *  |___ [__] |--< |\/| *
 * ____________________ *
 *
 * THE CORM PROJECT
 *
 * This file may only be used in accordance with the
 * terms of the Academic Free License ("AFL") v. 3.0,
 * as published by the Open Software Initiative.  A
 * copy of this license is provided in this source
 * release, and may be viewed online at:
 *
 * (http://www.opensource.org/licenses/afl-3.0.php)
 */
package org.eremite.corm.party.relationship;

import org.eremite.corm.BaseArchetype;
import org.eremite.corm.party.Binding;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
import java.util.Arrays;

@Entity
public class PartyRelationshipType extends BaseArchetype {

    @OneToMany(cascade={
            CascadeType.PERSIST,
            CascadeType.MERGE,
            CascadeType.REMOVE})
    private Set<Binding> properties = new HashSet<Binding>();

    /* Default Constructor */
    public PartyRelationshipType(){}

    /* Convenience Constructor */
    public PartyRelationshipType(String name, String desc){
        setName(name);
        setDescription(desc);
    }
    
    public Set<Binding> getProperties() {
        return properties;
    }

    public void setProperties(Set<Binding> properties) {
        this.properties = properties;
    }

    public void addProperty(Binding ... properties) {
        getProperties().addAll(Arrays.asList(properties));
    }

    public void addProperty(Binding property) {
        getProperties().add(property);
    }

//    public boolean canPlayRole(Party party) { throw new NotImplementedException(); }

//    public Set<PartyRelationshipConstraint> getConstraints() {
//        return this.constraints;
//    }
//    public void setConstraints(Set<PartyRelationshipConstraint> constraints) {
//        this.constraints = constraints;
//    }
}
